<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<title>选择房号</title>
		<link rel="stylesheet" href="../../css/amazeui.min.css">
		<link rel="stylesheet" href="css/app.css">
		<style>
		</style>
	</head>
	<body>
	
	<div id='header' class="am-g am-topbar-fixed-top" >
		<div  onclick="api.closeWin();"  class="am-u-sm-2" style="margin-top:12px;padding-left: 17px">
			<img  src="images/arr-l.png" style="height:14px;height: 18px;"/>
		</div>
		<div class="am-u-sm-8 til" style="margin-top:13px;text-align:center;">
			<h1>选择房号</h1>
		</div>
		<div class="am-u-sm-2" style="font-size: 20px;margin-top:10px;color:white;text-align:center;"></div>
	</div>
		
		
	<div class="am-g" style="margin-top:50px;" id="roomlist">

		
	
	
	</div>
		
		
		
		
	</body>
	
	
	
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript">
		apiready = function() {
		      
		      loadData();
		    
		};
		
		function loadData(){
		    
		    var unit=api.pageParam.unit;
		    
		    do_ajax('/app/getrooms?unit='+unit,'get',{},function(ret,err){
       
				  if(ret){
		                var  roomlist=ret;
					    var dataHtml = '';
					    if(roomlist.length>0){
					    
					       for(var i=0;i<roomlist.length;i++){
						        dataHtml += '<div class="am-u-sm-12"  onclick="selroom(\''+roomlist[i].name+'\')"  style="margin: 0px;background: white;padding:10px;border-bottom:1px solid #eaedf1;">'
					    		    dataHtml += '<span style="font-weight:bold;" >'+roomlist[i].name+'</span>';
					            dataHtml += '</div>';
					            
					         }
			        
					    }else{
					       
					       dataHtml += '<div  class="am-u-sm-12" style="margin-top:10px;text-align:center">暂无单元数据...</div>'
					         
					    }
                              
				    
				    
				        $api.html($api.byId('roomlist'), dataHtml);
						
						
						
						
						api.hideProgress();
					    
				       }else{
				            api.alert({
					            msg:('错误码：'+err.code+'；错误信息：'+err.msg+'网络状态码：'+err.statusCode)
					        });
					        api.hideProgress();
				       }
			   });
		
		};
		
		//选择单元
		function selroom(name){
		     
		    //发送选择单元事件
			api.sendEvent({
			    name: 'selectRoom',
			    extra: name                              
			});
		
			api.closeWin();
				
		};
		
		
		
		
		
	</script>
</html>